<?php
class Hvn_WidgetController extends Clu_Controller_Action_Widget
{
	
	public function init()
	{
		//require_once (APP_PATH.'/library/common.php');
		//require_once (APP_PATH.'/modules/place/Model/City.php');
		//require_once (APP_PATH.'/modules/place/Form/PlaceSearch.php');
		//require_once (APP_PATH.'/modules/article/Model/Article.php');
		//require_once (APP_PATH.'/modules/event/Model/Event.php');
		//require_once (APP_PATH.'/modules/category/Model/Category.php');
		//require_once (APP_PATH.'/modules/category/Model/Category.php');
		//require_once (APP_PATH.'/modules/node/Model/NodeService.php');
//		$this->mCommon   = new place_Model_Place();
		$this->mPlace   = new place_Model_Place();
		$this->mCity    = new place_Model_City();
		$this->mArticle = new article_Model_Service();
		$this->mCategory = new category_Model_Category();
		$this->mCategory->setTables('news');
		$this->mService = new node_Model_NodeService();
		$this->mUser = new user_Model_User();
		parent::init();
	}
	
	public function homeAction()
	{
		//echo('123');
//		die();
		
	}
	public function menuAction()
	{
		$auth = Zend_Auth::getInstance();
		$uIdentity = $auth->getIdentity();
		if(isset($uIdentity))
		{
			$role_id = $uIdentity->id;
			$result = $this->mUser->getUserRoles($role_id);
	    	$ret = explode(',', $result);
	    	$this->viewParams['role_id'] = $ret;
		}	
		//truyen $this->viewParams[] cho cai file 1--widget--menu
		
	}
	
	public function footerAction()
	{
		
	}
	
	public function advertisementAction()
	{
		
	}
	
	public function infoAction()
	{
	$this->viewParams['onYahoo'] =  get_key("hvn_sales_ym");
	$this->viewParams['onSkype'] =  get_key("hvn_sales_skype");
//	die($this->viewParam['onYM']);	
		
	}
	public function albumAction()
	{
		
	}
	
	public function	listMenuAction()
	{
		
	}
	
	public function	blogAction()
	{
		
	}
	
	public function aboutVietnamAction()
	{
		
	}
	
	public function vietnamAction()
	{
		$this->viewParams['category_news'] = $this->mCategory->getTree(2, 0, 1);
		$data = null;
		$this->viewParams['type'] = 'news';
		$nodeTypeInfo = $this->mService->getNodeTypeInfo($this->viewParams['type']);
		$newsContent = $this->mService->search($data,$nodeTypeInfo);
		$this->viewParams['news_content'] = $this->db->fetchAll($newsContent);
	}
	public function mapAction()
	{
		$listCity = $this->mCity->findForSelect();
		$this->viewParams['listCity'] = $listCity;
	}
	
	public function heritageAction()
	{
		$data = array('category' => 9);
		$this->viewParams['type'] = 'news';
		$nodeTypeInfo = $this->mService->getNodeTypeInfo($this->viewParams['type']);
		$newsContent = $this->mService->search($data,$nodeTypeInfo);
		$this->viewParams['news_content'] = $this->db->fetchAll($newsContent);
	}
	public function foodAction()
	{
		$data = array('category' => 12);
		$this->viewParams['type'] = 'news';
		$nodeTypeInfo = $this->mService->getNodeTypeInfo($this->viewParams['type']);
		$newsContent = $this->mService->search($data,$nodeTypeInfo);
		$this->viewParams['news_content'] = $this->db->fetchAll($newsContent);
	}
	
	public function folkArtAction()
	{
		$data = array('category' => 18);
		$this->viewParams['type'] = 'news';
		$nodeTypeInfo = $this->mService->getNodeTypeInfo($this->viewParams['type']);
		$newsContent = $this->mService->search($data,$nodeTypeInfo);
		$this->viewParams['news_content'] = $this->db->fetchAll($newsContent);
	}
	
	public function linkAction()
	{
		
	}
	
	public function listCategoryAction()
	{
		//require_once (APP_PATH.'/modules/category/Model/Category.php');
    	$mCategory = new category_Model_Category();
    	$mCategory->setTables('place');
    	$this->viewParams['listCategory'] = $mCategory->getRootType('Root_Place');
    	  $sess = new Zend_Session_Namespace(CLU_NS);
    	  
    if ($this->issetParam('searchCondition'))
    	  {
    	      $this->viewParams['searchCondition'] = "&city_id=".$this->getParam('searchCondition');    
    	     // die($this->viewParams['searchCondition'] );
    	  }
    	  
	}
	
	public function supportAction()
	{
	$this->viewParams['onYahoo'] =  get_key("hvn_sales_ym");
	$this->viewParams['onSkype'] =  get_key("hvn_sales_skype");
	}

	public function mapPlaceAction()
	{
		$placeId = $this->miniRequest['placeId'];
		$regionId = $this->miniRequest['regionId'];
		$boxWeight = $this->miniRequest['boxWeight'];
		$category_rtype = $this->miniRequest['category_rtype'];
		$this->view->placeId = $placeId;
//		if($category_rtype == 90)
		{
			$this->renderToHolder('block/mapvietnam.phtml', true, null, $regionId, $boxWeight);
		}
	}
	
	public function mapVietnamAction()
	{
		$regionId = $this->miniRequest['regionId'];
		$boxWeight = $this->miniRequest['boxWeight'];
		$this->renderToHolder('block/mapvietnam.phtml', true, null, $regionId, $boxWeight);
		//$this->renderToHolder('block/social_bookmarking.phtml', true, 5, 2);
	}
	
	public function onlineSupportAction()
	{
		//online support
		$regionId = $this->miniRequest['regionId'];
		$boxWeight = $this->miniRequest['boxWeight'];
		///TODO
		$this->renderToHolder('block/onlineSupport.phtml', true, null, $regionId, $boxWeight);
	}
	
	public function mainMenuAction()
	{
		$regionId = $this->miniRequest['regionId'];
		$boxWeight = $this->miniRequest['boxWeight'];
		$this->renderToHolder('block/mainMenu.phtml', false, null, $regionId, $boxWeight);
	}
}
?>